from django.db import models

# Create your models here.
from stock.models import Goods


class Indent(models.Model):
    indent_id = models.CharField(primary_key=True, max_length=32)
    num = models.CharField(max_length=10, blank=True, null=True)
    price = models.IntegerField(blank=True, null=True)
    sign_name = models.CharField(max_length=20, blank=True, null=True)
    phone = models.CharField(max_length=11, blank=True, null=True)
    address = models.CharField(max_length=50, blank=True, null=True)
    type = models.CharField(max_length=20,blank=True,null=True)
    indent_status = models.CharField(max_length=10, blank=True, null=True)
    pay_status = models.CharField(max_length=10, blank=True, null=True)
    appr_num = models.CharField(max_length=10, blank=True, null=True)
    create_time = models.DateTimeField(blank=True, null=True)
    update_time = models.DateTimeField(blank=True, null=True)
    staff_name = models.CharField(max_length=20, blank=True, null=True)
    staff_num = models.CharField(max_length=10, blank=True, null=True)
    company = models.CharField(max_length=50, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'indent'


class IndentDetail(models.Model):
    indentdet_id = models.CharField(primary_key=True, max_length=32)
    indent = models.ForeignKey(Indent, on_delete=models.DO_NOTHING, blank=True, null=True)
    goods = models.ForeignKey(Goods, on_delete=models.DO_NOTHING, blank=True, null=True)
    count = models.IntegerField(blank=True, null=True)
    price = models.IntegerField(blank=True, null=True)


    class Meta:
        managed = False
        db_table = 'indent_detail'


class IndentHistory(models.Model):
    history_id = models.CharField(primary_key=True, max_length=32)
    num = models.CharField(max_length=10, blank=True, null=True)
    goods_name = models.CharField(max_length=32, blank=True, null=True)
    price = models.FloatField(blank=True, null=True)
    count = models.IntegerField(blank=True, null=True)
    total_price = models.FloatField(blank=True, null=True)
    address = models.CharField(max_length=50, blank=True, null=True)
    sign_name = models.CharField(max_length=20, blank=True, null=True)
    phone = models.CharField(max_length=11, blank=True, null=True)
    finish_time = models.DateTimeField(blank=True, null=True)
    staff_name = models.CharField(max_length=20, blank=True, null=True)
    staff_num = models.CharField(max_length=10, blank=True, null=True)
    company = models.CharField(max_length=50, blank=True, null=True)
    create_time = models.DateTimeField(blank=True, null=True)
    indent_status = models.CharField(max_length=10, blank=True, null=True)

    class Meta:
        managed = False
        db_table = 'indent_history'
